package com.isky.visual.proj.mapper;

import com.isky.visual.proj.entity.PanelGroup;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.isky.visual.proj.entity.vo.ProjectVisualVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * <p>
 * 项目分组表 Mapper 接口
 * </p>
 *
 * @author wudl
 * @since 2020-04-28
 */
@Mapper
public interface PanelGroupMapper extends BaseMapper<PanelGroup> {

    @Select("SELECT pp.id, pp.project_name FROM panel_group_t p LEFT JOIN project_t pp ON p.id = pp.group_id WHERE p.user_id = #{userId} and p.group_type = #{type}")
    public List<ProjectVisualVO> getAllPublishVisual(@Param("userId")long userId,@Param("type")int type);

    public List<PanelGroup> selectBYNameAndUserId(@Param("userId")long userId,@Param("groupName")String groupName,@Param("type")int type);

    public List<PanelGroup> getGroupDashboard(@Param("userId")long userId,@Param("type")int type);

    PanelGroup selectByGroupId(@Param("groupId")Long groupId);

    PanelGroup selectRoot(@Param("groupType") Integer groupType, @Param("userId")Long userId);

    /**
     * 查询所有人共有的项目组id
     * @return
     */
    PanelGroup selectAllShareRoot();
}
